package com.webguard.outlierdetection.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;

public class AnomalyRecord {
    @JsonProperty("destination_port") // 添加Jackson注解
    private Integer destinationPort;

    @JsonProperty("flow_duration")
    private String flowDuration;

    @JsonProperty("flow_bytes_per_s")
    private String flowBytesPerS;

    @JsonProperty("flow_packets_per_s")
    private String flowPacketsPerS;

    @JsonProperty("syn_flag_count")
    private Integer synFlagCount;

    @JsonProperty("rst_flag_count")
    private Integer rstFlagCount;

    @JsonProperty("ack_flag_count")
    private Integer ackFlagCount;

    @JsonProperty("type")
    private String type;

    // Getter and Setter methods
    public Integer getDestinationPort() {
        return destinationPort;
    }

    public void setDestinationPort(Integer destinationPort) {
        this.destinationPort = destinationPort;
    }

    public String getFlowDuration() {
        return flowDuration;
    }

    public void setFlowDuration(String flowDuration) {
        this.flowDuration = flowDuration;
    }

    public String getFlowBytesPerS() {
        return flowBytesPerS;
    }

    public void setFlowBytesPerS(String flowBytesPerS) {
        this.flowBytesPerS = flowBytesPerS;
    }

    public String getFlowPacketsPerS() {
        return flowPacketsPerS;
    }

    public void setFlowPacketsPerS(String flowPacketsPerS) {
        this.flowPacketsPerS = flowPacketsPerS;
    }

    public Integer getSynFlagCount() {
        return synFlagCount;
    }

    public void setSynFlagCount(Integer synFlagCount) {
        this.synFlagCount = synFlagCount;
    }

    public Integer getRstFlagCount() {
        return rstFlagCount;
    }

    public void setRstFlagCount(Integer rstFlagCount) {
        this.rstFlagCount = rstFlagCount;
    }

    public Integer getAckFlagCount() {
        return ackFlagCount;
    }

    public void setAckFlagCount(Integer ackFlagCount) {
        this.ackFlagCount = ackFlagCount;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    // Full-argument constructor
    public AnomalyRecord(Integer destinationPort, String flowDuration, String flowBytesPerS, String flowPacketsPerS,
                         Integer synFlagCount, Integer rstFlagCount, Integer ackFlagCount, String type) {
        this.destinationPort = destinationPort;
        this.flowDuration = flowDuration;
        this.flowBytesPerS = flowBytesPerS;
        this.flowPacketsPerS = flowPacketsPerS;
        this.synFlagCount = synFlagCount;
        this.rstFlagCount = rstFlagCount;
        this.ackFlagCount = ackFlagCount;
        this.type = type;
    }

    // Default constructor
    public AnomalyRecord() {
    }

    @Override
    public String toString() {
        return String.format(
                "{\"destinationPort\": %d, \"flowDuration\": \"%s\", \"flowBytesPerS\": \"%s\", \"flowPacketsPerS\": \"%s\", " +
                        "\"synFlagCount\": %d, \"rstFlagCount\": %d, \"ackFlagCount\": %d, \"type\": \"%s\"}",
                destinationPort, flowDuration, flowBytesPerS, flowPacketsPerS,
                synFlagCount, rstFlagCount, ackFlagCount, type
        );
    }
}
